package com.zw.goodsservice.common;

import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.IdentifierGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.Serializable;

/**
 * 自定义主键生成器
 */
@Component
public class SnowflakeId implements IdentifierGenerator {

    @Autowired
    private SnowflakeIdGenerator idGen;

    @Override
    public Serializable generate(SharedSessionContractImplementor sharedSessionContractImplementor, Object o) {
        return idGen.nextId();
    }
}
